package com.itheima.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.pojo.Order;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Map;

public interface OrderMapper extends BaseMapper<Order> {

    @Select("select COUNT(*) from t_order where MEMBER_ID = #{id} and ORDERDATE = #{orderDate} and SETMEAL_ID = #{setmealId}")
    int findOrderIsExist(@Param("id") Integer id,@Param("orderDate") String orderDate,@Param("setmealId") String setmealId);

    @Select("select " +
            "tmb.name memberName," +
            "tsm.name setmealName," +
            "td.ORDERDATE orderDate," +
            "td.ORDERTYPE orderType " +
            "from t_order td,t_member tmb,t_setmeal tsm " +
            "where td.id = #{id} " +
            "and td.MEMBER_ID = tmb.id " +
            "and td.SETMEAL_ID = tsm.id")
    Map findMemberNameAndSetmealNameAndOrderById(Integer id);
}
